<?php

namespace Biz\model\stat;

use Doraemon\pockets\datebase\BaseDbModel;

class GoodsTag extends BaseDbModel
{

    const _CONFIG_FILE_ = 'db_stat';

    const _CONFIG_SELECT_ = 'db_stat_json';

    const _DATABASE_ = 'stat';

    const _TABLE_NAME = 'goods_tag';

    public static function getGoodsTagByGoodsId($goodsId)
    {
        $tag = self::get('tag', [
            'goods_id' => $goodsId,
            'ORDER' => ['id' => 'DESC']
        ]);
        return $tag ?: "";
    }

    public static function getListByGoodsIds($goodsIds)
    {
        $infos = self::select("*", [
            'date' => date("Y-m-d"),
            'goods_id' => $goodsIds
        ]);
        return array_column($infos, null, 'goods_id');
    }

}